package com.rzico.sbl.ui.mine

import android.widget.Button
import com.rzico.sbl.R
import com.rzico.sbl.databinding.ActivityCommonListBinding
import com.rzico.sbl.model.CommonData
import com.xinnuo.common.decoration.SpaceTBDecoration
import com.xinnuo.common.extend.startActivityEx
import com.xinnuo.common.extend.find
import com.xinnuo.common.extend.oneClick
import com.xinnuo.common_ui.base.BaseActivity
import com.xinnuo.common_ui.base.loadLinear
import com.xinnuo.slimadapter.SlimAdapter

class WalletBankActivity : BaseActivity(R.layout.activity_common_list) {

    private val mBinding by lazy { ActivityCommonListBinding.bind(getRootView()) }

    override fun initData() {
        initTitle(title = "银行卡")

        initLayout()
    }

    private fun initLayout() {
        mBinding.listLayout.apply {
            emptyLayout.also {
                it.emptyHint.text = "暂无相关银行卡信息！"
            }

            recycleList.also { layout ->
                layout.loadLinear(
                    refresh = swipeRefresh,
                    onRefresh = { },
                    onLoad = { }
                )

                layout.addItemDecoration(SpaceTBDecoration())

                mAdapter = SlimAdapter.creator()
                    .register<CommonData>(R.layout.item_wallet_bank) { jector, _, _ ->
                        jector.apply { }
                    }
                    .attachTo(layout)
                    .addFooter(baseContext, R.layout.footer_wallet_bank) { _, view ->
                        view.find<Button>(R.id.bt_add)
                            .oneClick {
                                startActivityEx<WalletAddActivity>()
                            }
                    }
            }
        }
    }

}